﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="cn_shopping_cart" Codebehind="shopping_cart.aspx.cs" %>


<%@ Register Src="~/cn/UserControl/header.ascx" TagName="header" TagPrefix="uc1" %>
<%@ Register Src="~/cn/UserControl/footer.ascx" TagName="footer" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>我的购物车，<%=(new Gift.WebApp.BasicSet()).TitleBind() %></title>
    <meta name="Keywords" content="<%=(new Gift.WebApp.BasicSet()).KeywordBind() %>" />
    <meta name="Description" content="<%=(new Gift.WebApp.BasicSet()).DescriptionBind() %>" />
    <link type="text/css" rel="stylesheet" href="/script/css/index.css" />
    <link type="text/css" rel="stylesheet" href="/script/css/member.css" />
    <link type="text/css" rel="stylesheet" href="/script/css/ie.css" />

    <script type="text/javascript" src="/script/js/jquery-1.6.2.min.js"></script>

    <script type="text/javascript">
        function send_request(url, poststr) {
            http_request = false;
            if (window.XMLHttpRequest) {
                http_request = new XMLHttpRequest();
                if (http_request.overrideMimeType) {
                    http_request.overrideMimeType('text/xml');
                }
            } else if (window.ActiveXObject) {
                try {
                    http_request = new ActiveXObject("Msxml2.XMLHTTP");
                } catch (e) {
                    try {
                        http_request = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch (e) { }
                }
            }
            if (!http_request) return false;
            http_request.onreadystatechange = processRequest;
            http_request.open("POST", url, true);
            http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            http_request.send(poststr);
        }
        function processRequest() {
            if (http_request.readyState == 4) {
                if (http_request.status == 200) {
                    if (http_request.responseText == "")
                        art.dialog.tips("很抱歉，商品数量修改失败！", 1.5);
                    else {
                        var returnValue = http_request.responseText.split("〇");
                        if (returnValue[0] == "1")
                            art.dialog.tips("很抱歉，商品数量修改失败,商品库存不足！", 1.5);
                        $("#tbShoppingCart").html(returnValue[1]);
                        $("#pTotal").html(returnValue[2]);
                    }
                } else { art.dialog.tips("很抱歉，商品数量修改失败！", 1.5); }
            }
        }

        function amountJia(obj) {

            poststr = "cid=" + obj + "&amount=" + (parseInt($("#amount" + obj).val()) + 1);
            send_request("shoppingCartHandler.ashx", poststr, function () {
                if (http_request.readyState == 4 && http_request.status == 200) {
                    changeShoppingCart(http_request.responseText);
                }
            });
        }
        function amountJian(obj) {
            if (parseInt($("#amount" + obj).val()) > 1) {
                poststr = "cid=" + obj + "&amount=" + (parseInt($("#amount" + obj).val()) - 1);
                send_request("shoppingCartHandler.ashx", poststr, function () {
                    if (http_request.readyState == 4 && http_request.status == 200) {
                        changeShoppingCart(http_request.responseText);
                    }
                });
            }
        }


        function changeAmount(obj) {
            if (parseInt($("#amount" + obj).val()) == 0) {
                art.dialog.tips("购买数量不能为0！", 5);
                return false;
            }
            poststr = "cid=" + obj + "&amount=" + $("#amount" + obj).val();
            send_request("shoppingCartHandler.ashx", poststr, function () {
                if (http_request.readyState == 4 && http_request.status == 200) {
                    changeShoppingCart(http_request.responseText);
                }
            });
        }

        $(function () {
            $("#imgSettlement").click(function () {
                $.ajax({
                    type: "POST",
                    url: "detectionSessionHandler.ashx",
                    success: function (msg) {
                        if (msg == "0")
                            TB_show(null, "login.html?TB_iframe=true&height=370&width=640", false);
                        else if (msg == "1")
                            art.dialog.tips("购物车目前没有加入任何商品！", 1.5);
                        else if (msg == "2")
                            window.location = "order_info.html";
                    }
                });
                return false;
            });
        });
    </script>

</head>
<body>
    <uc1:header ID="Header1" runat="server" />
    <div class="container">
        <div class="rightcontent shop_cart border_no">
            <a class="clearcart" href="javascript:" onclick="customButton('确定要清空购物车吗？','确定','shoppingCartHandler.ashx?sid=all','取消');">
                清空购物车</a>
            <h5>
                <span><strong>1.我的购物车</strong></span><span>2.填写购物信息</span><span>3.成功下订</span></h5>
            <table id="tbShoppingCart">
                <tr>
                    <th>
                        商品货号</th>
                    <th>
                        商品图片</th>
                    <th>
                        商品名称</th>
                    <th>
                        销售价格</th>
                    <th>
                        数量</th>
                    <th>
                        小计</th>
                    <th>
                        删除</th>
                </tr>
                <%Response.Write(ShoppingCartBind()); %>
            </table>
            <span class="cartbtn">
                <img src="/script/images/shopcar.gif" onclick="javascript:window.location='index.html';"
                    alt="<<继续购物" />
                <img id="imgSettlement" src="/script/images/account.jpg" alt="￥去结算" /></span>
            <%Response.Write(ShoppingCartTotalBind()); %>
        </div>
        <!--end rightcontent-->
        <span class="clear"></span>
    </div>
    <uc2:footer ID="Footer1" runat="server" />
</body>
</html>
